<?php

/** 
 * @author Administrator
 * 
 * 
 */
class keke_admin_class {
	static function get_admin_menu() {
		global $model_list, $_cache_obj;
		$menuset_arr = $_cache_obj->get ( 'menu_resource_cache' );
		if (! $menuset_arr) {
			$resource_obj = new Keke_witkey_resource_class ();
			$resource_obj->setWhere ( "1=1 order by listorder asc" );
			$resource_arr = $resource_obj->query_keke_witkey_resource ();
			$resource_submenu_obj = new Keke_witkey_resource_submenu_class ();
			$resource_submenu_obj->setWhere ( "1=1 order by listorder" );
			$resource_sub_arr = $resource_submenu_obj->query_keke_witkey_resource_submenu ();
			
			$temp_arr = array ();
			$temp_arr2 = array ();
			$resource_set_arr = array ();
			$submenu_set_arr = array ();
			foreach ( $resource_arr as $r_tp ) {
				$resource_set_arr [$r_tp ['resource_id']] = $r_tp;
				$temp_arr [$r_tp ['submenu_id']] [] = $r_tp;
			}
			foreach ( $resource_sub_arr as $r_tp ) {
				$submenu_set_arr [$r_tp ['submenu_id']] = $r_tp;
				$temp_arr2 [$r_tp ['menu_name']] [] = array ('name' => $r_tp ['submenu_name'], 'items' => $temp_arr [$r_tp ['submenu_id']] );
			}
			$resource_arr = $temp_arr2;
			$menuset_arr = array ('menu' => $resource_arr, 'submenu' => $submenu_set_arr, 'resource' => $resource_set_arr );
			
			$model_list = $model_list ? $model_list : kekezu::get_table_data ( 'witkey_model', 'model_status=1', '', null, 'model_id' );
			$i = 0;
			foreach ( $model_list as $model ) {
				$task_menu_arr = array ();
				if (! file_exists ( S_ROOT . 'task/' . $model ['model_dir'] . '/control/admin/task_config.php' )) {
					continue;
				}
				require S_ROOT . 'task/' . $model ['model_dir'] . '/control/admin/task_config.php';
				$mulist_arr = array ();
				foreach ( $task_menu_arr as $k => $v ) {
					$mulist_arr [] = array ('resource_id' => "m{$model['model_id']}" . $i ++, 'resource_name' => $k, 'resource_url' => $v );
				}
				
				$menuset_arr ['menu'] ['task'] [] = array ('name' => $model ['model_name'], 'items' => $mulist_arr );
			}
			
			$_cache_obj->set(  'menu_resource_cache',$menuset_arr );
		}
		return $menuset_arr;
	}
	
	static function get_user_group() {
		global $_cache_obj;
		$group_arr = $_cache_obj->get ( "member_group_cache" );
		if (! $group_arr) {
			$membergroup_obj = new Keke_witkey_member_group_class ();
			$group_arr = $membergroup_obj->query_keke_witkey_member_group ();
			$temp_arr = array ();
			foreach ( $group_arr as $v ) {
				$temp_arr [$v ['group_id']] = $v;
				$temp_arr [$v ['group_id']] ['group_roles'] = explode ( ',', $v ['group_roles'] );
			}
			$group_arr = $temp_arr;
			$_cache_obj->set ( 'member_group_cache', $group_arr );
		}
		
		return $group_arr;
	}
	
 	
	static function get_article_cate() {
		global $_cache_obj;
		$category_arr = $_cache_obj->get ( "keke_witkey_article_category" );
		if (! $category_arr) {
			$category_obj = new Keke_witkey_article_category_class ();
			$category_obj->setWhere ( ' 1 = 1 order by listorder asc ' );
			$category_arr = $category_obj->query_keke_witkey_article_category ();
			$temparr = array ();
			foreach ( $category_arr as $inarr ) {
				$temparr [$inarr ['art_cat_id']] = $inarr;
			}
			$category_arr = $temparr;
			$_cache_obj->set (  "keke_witkey_article_category",$category_arr );
		}
		
		return $category_arr;
	
	}

}

?>